package ph.com.gs3.formalistics.presenter.adapters;

import java.util.HashMap;
import java.util.Map;

import ph.com.gs3.formalistics.presenter.fragments.views.OnlineUsersViewFragment;
import ph.com.gs3.formalistics.presenter.fragments.views.ThreadListViewFragment;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

public class MessengerViewPagerAdapter extends FragmentPagerAdapter {

	private Map<Integer, Fragment> viewFragments;
	private Map<Integer, String> fragmentTitles;

	public MessengerViewPagerAdapter(FragmentManager fm) {
		super(fm);
		initializeFragments();
		initializeFragmentTitles();
	}

	@Override
	public String getPageTitle(int position) {
		return fragmentTitles.get(position);
	}

	@Override
	public Fragment getItem(int position) {
		return viewFragments.get(position);
	}

	@Override
	public int getCount() {
		return viewFragments.size();
	}

	private void initializeFragments() {
		viewFragments = new HashMap<>();
		viewFragments.put(0, ThreadListViewFragment.createInstance());
		viewFragments.put(1, OnlineUsersViewFragment.createInstance());
	}

	private void initializeFragmentTitles() {
		fragmentTitles = new HashMap<>();
		fragmentTitles.put(0, ThreadListViewFragment.TITLE);
		fragmentTitles.put(1, OnlineUsersViewFragment.TITLE);
	}

}
